package com.haixiaoke.saas.enterprise.order.controller;


import com.haixiaoke.saas.common.annotation.Log;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.core.page.TableDataInfo;
import com.haixiaoke.saas.common.enums.BusinessType;
import com.haixiaoke.saas.order.domain.CheckOutOrder;
import com.haixiaoke.saas.order.service.ICheckOutOrderService;
import com.haixiaoke.saas.system.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 退房订单Controller
 * 
 * @author panda
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/enterprise/checkOutOrder")
public class EnterpriseCheckOutOrderController extends BaseController {
    @Autowired
    private ICheckOutOrderService checkOutOrderService;

    /**
     * 查询退房订单列表
     */
//    @PreAuthorize("@ss.hasPermi('business:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckOutOrder checkOutOrder) {
        startPage();
        List<CheckOutOrder> list = checkOutOrderService.selectCheckOutOrderList(checkOutOrder);
        return getDataTable(list);
    }

    /**
     * 获取退房订单详细信息
     */
//    @PreAuthorize("@ss.hasPermi('business:order:query')")
    @GetMapping(value = "/{checkOutOrderId}")
    public AjaxResult getInfo(@PathVariable("checkOutOrderId") String checkOutOrderId) {
        return success(checkOutOrderService.selectCheckOutOrderByCheckOutOrderId(checkOutOrderId));
    }

    /**
     * 新增退房订单
     */
//    @PreAuthorize("@ss.hasPermi('business:order:add')")
    @Log(title = "退房订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckOutOrder checkOutOrder) {
        return toAjax(checkOutOrderService.insertCheckOutOrder(checkOutOrder));
    }

    /**
     * 修改退房订单
     */
//    @PreAuthorize("@ss.hasPermi('business:order:edit')")
    @Log(title = "退房订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckOutOrder checkOutOrder) {
        return toAjax(checkOutOrderService.updateCheckOutOrder(checkOutOrder));
    }

    /**
     * 删除退房订单
     */
//    @PreAuthorize("@ss.hasPermi('business:order:remove')")
    @Log(title = "退房订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkOutOrderIds}")
    public AjaxResult remove(@PathVariable String[] checkOutOrderIds) {
        return toAjax(checkOutOrderService.deleteCheckOutOrderByCheckOutOrderIds(checkOutOrderIds));
    }
}
